﻿using Coldairarrow.Business.PB;
using Coldairarrow.Entity.DingReving;
using Coldairarrow.Entity.PB;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.PB
{
    [Route("/PB/[controller]/[action]")]
    public class PB_CallPackListController : BaseApiController
    {
        #region DI

        public PB_CallPackListController(IPB_CallPackListBusiness pB_CallPackListBus)
        {
            _pB_CallPackListBus = pB_CallPackListBus;
        }

        IPB_CallPackListBusiness _pB_CallPackListBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<PB_CallPackList>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _pB_CallPackListBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<PB_CallPackList> GetTheData(IdInputDTO input)
        {
            return await _pB_CallPackListBus.GetTheDataAsync(input.id);
        }

        #endregion

        #region 提交
        /// <summary>
        /// 待维打包生产待维包码
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task SaveData(PB_CallPackList data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _pB_CallPackListBus.AddDataAsync(data);
            }
            else
            {
                await _pB_CallPackListBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _pB_CallPackListBus.DeleteDataAsync(ids);
        }
        /// <summary>
        /// 扫描单个物料成品获取物料信息
        /// </summary>
        [HttpPost]
        public async Task<PB_Material> GetMaterial(string QrCode) {
            return await _pB_CallPackListBus.GetMaterial(QrCode);
        }
        [HttpPost]
        public async Task AddCallPackList(List<AddCallPackList> addCallPackLists) {
            await _pB_CallPackListBus.AddCallPackList(addCallPackLists);
        }
        #endregion
    }
}